cssanimatedstyle: Avoid unnecessary transition work
authorTimm Bäder <mail@baedert.org>
Mon, 19 Aug 2019 06:45:07 +0000 (08:45 +0200)
committerTimm Bäder <mail@baedert.org>
Mon, 9 Sep 2019 15:36:23 +0000 (17:36 +0200)
No need to do all the transition work if the transition duration will be
0 for all of them.

gtk/gtkcssanimatedstyle.c

index 2b7545184084e7afbd7b4b2b78000f8cdad9a47a..21cc98c4fc234ec52df921229fec145681d03828 100644 (file)
@@ -272,12 +272,18 @@ gtk_css_animated_style_create_css_transitions (GSList              *animations,
   GtkCssValue *durations, *delays, *timing_functions;
   guint i;
 
-  transition_infos_set (transitions, gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_PROPERTY));
-
   durations = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_DURATION);
   delays = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_DELAY);
   timing_functions = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION);
 
+  if (_gtk_css_array_value_get_n_values (durations) == 1 &&
+      _gtk_css_array_value_get_n_values (delays) == 1 &&
+      _gtk_css_number_value_get (_gtk_css_array_value_get_nth (durations, 0), 100) +
+      _gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, 0), 100) == 0)
+    return animations;
+
+  transition_infos_set (transitions, gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_PROPERTY));
+
   for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
     {
       GtkStyleAnimation *animation;